﻿<%@ WebHandler Language="C#" Class="PersonnelFile" %>

using System;
using System.Web;
using System.Data;
using System.Text;
using System.IO;
using Chenxin.Lib.Utility;
using System.Collections.Generic;

public class PersonnelFile : AjaxHandlerBase
{
    private string ShowInfoId = "", ShwoUserChangeCount = "", ShwoUserChangeData = "",
        ShowPositionPowerCount = "", ShowPositionPowerData = "", ShowBussinessCount = "", ShowBussinessData = "";
    override public void RequestProcess(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Buffer = true;
        context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShowInfoId"]))
        {
            ShowInfoId = context.Request.QueryString["ShowInfoId"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShwoUserChangeCount"]))
        {
            ShwoUserChangeCount = context.Request.QueryString["ShwoUserChangeCount"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShwoUserChangeData"]))
        {
            ShwoUserChangeData = context.Request.QueryString["ShwoUserChangeData"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShowPositionPowerCount"]))
        {
            ShowPositionPowerCount = context.Request.QueryString["ShowPositionPowerCount"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShowPositionPowerData"]))
        {
            ShowPositionPowerData = context.Request.QueryString["ShowPositionPowerData"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShowBussinessCount"]))
        {
            ShowBussinessCount = context.Request.QueryString["ShowBussinessCount"];
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["ShowBussinessData"]))
        {
            ShowBussinessData = context.Request.QueryString["ShowBussinessData"];
        }
        StringBuilder sb = null;
        if (ShowInfoId != "")
        {
            sb = GetData();
        }
        if (ShwoUserChangeCount != "")
        {
            sb = GetUserChangeCount();
        }
        if (ShwoUserChangeData != "")
        {
            GetUserChangeData(context);
            return;
        }
        if (ShowPositionPowerCount != "")
        {
            sb = GetPositionPowerCount();
        }
        if (ShowPositionPowerData != "")
        {
            GetPositionPowerData(context);
            return;
        }
        if (ShowBussinessCount != "")
        {
            sb = GetBussinessCount();
        }
        if (ShowBussinessData != "")
        {
            GetBussinessData(context);
            return;
        }
        context.Response.Write(sb.ToString());
    }

    private StringBuilder GetData()
    {
        StringBuilder strb = new StringBuilder();
        Chenxin.Lib.Passport.Entity.Hr_UserInfo hr_info = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityById(new Guid(ShowInfoId));
        if (hr_info != null)
        {
            strb.Append("[{RecoderID:'" + hr_info.UserId.ToString() + "' ,UserCode:'" + hr_info.UserCode + "',BelongCityName:'" + hr_info.BelongCityName);
            strb.Append("',BelongCompanyName: '" + hr_info.BelongCompanyName);
            strb.Append("',BelongDepart: '" + hr_info.BelongDepart);
            strb.Append("',UserName: '" + hr_info.UserName);
            string sex = "";
            if (hr_info.Sex != null)
            {
                sex = hr_info.Sex.Value == 0 ? "男" : "女";
            }
            strb.Append("',UserSex: '" + sex);
            strb.Append("',Education: '" + hr_info.Education);
            strb.Append("',IDType: '" + hr_info.IDType);
            strb.Append("',IDNo: '" + hr_info.IDNo);
            string birthday = "";
            if (hr_info.BirthDay != null)
            {
                birthday = hr_info.BirthDay.Value.ToString("yyyy-MM-dd");
            }
            strb.Append("',BirthDay: '" + birthday);
            strb.Append("',Address: '" + hr_info.Address);
            strb.Append("',Mobile: '" + hr_info.Mobile);
            strb.Append("',HomeTel: '" + hr_info.HomeTel);
            strb.Append("',OfficeTel: '" + hr_info.OfficeTel);
            strb.Append("',BankNo: '" + hr_info.BankNo);
            strb.Append("',Position: '" + hr_info.Position);
            strb.Append("',EmpLevel: '" + hr_info.EmpLevel);
            strb.Append("',FundCode: '" + hr_info.FundCode);
            string workAge = "";
            if (hr_info.WorkAgeBegin == null)
            {
                workAge = "0年";
            }
            else
            {
                if (DateTime.Now.Year > hr_info.WorkAgeBegin.Value.Year)
                {
                    workAge = Convert.ToString(DateTime.Now.Year - hr_info.WorkAgeBegin.Value.Year) + "年";
                }
                else
                {
                    workAge = "0年";
                }
            }
            strb.Append("',WorkAgeBegin: '" + workAge);
            strb.Append("',Email: '" + hr_info.Email);
            string ComeDate = "", ConBegin = "", ConEnd = "", AddTime = "", UplTime = "";
            if (hr_info.ComeDate != null)
            {
                ComeDate = hr_info.ComeDate.Value.ToString("yyyy-MM-dd");
            }
            if (hr_info.ConBegin != null)
            {
                ConBegin = hr_info.ConBegin.Value.ToString("yyyy-MM-dd");
            }
            if (hr_info.ConEnd != null)
            {
                ConEnd = hr_info.ConEnd.Value.ToString("yyyy-MM-dd");
            }
            if (hr_info.AddTime != null)
            {
                AddTime = hr_info.AddTime.Value.ToString("yyyy-MM-dd");
            }
            if (hr_info.UpdateTime != null)
            {
                UplTime = hr_info.UpdateTime.Value.ToString("yyyy-MM-dd");
            }
            strb.Append("',ComeDate: '" + ComeDate);
            strb.Append("',ConBegin: '" + ConBegin);
            strb.Append("',ConEnd: '" + ConEnd);
            strb.Append("',Remark: '" + hr_info.Remark.Replace("\r\n", "\\r\\n"));
            strb.Append("',AddTime: '" + AddTime);
            strb.Append("',UplTime: '" + UplTime);
            strb.Append("',Zip: '" + hr_info.Zip);
            strb.Append("',WorkRelation: '" + hr_info.WorkRelation);
            if (hr_info.PicUrlSmall.Length > 0)
            {
                strb.Append("',PicUrlSmall: '" + hr_info.PicUrl);
            }
            strb.Append("'}]");
        }

        return strb;

    }

    private StringBuilder GetUserChangeCount()
    {
        string strwhere = "UserId='" + ShwoUserChangeCount + "'";
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(1, 1, "AddTime desc", "Hr_PersonnelTransferInfo", strwhere, "UserId", "UserId", false);
        StringBuilder str = new StringBuilder();
        str.Append("{count:'" + ds.Tables[0].Rows[0][0].ToString() + "'}");
        return str;
    }

    private void GetUserChangeData(HttpContext context)
    {
        int pageindex = 0;//页码
        int PageSize = 0;//页显示行数
        string strwhere = "";
        //页码        
        if (!string.IsNullOrEmpty(context.Request.QueryString["pageindex"]))
        {
            pageindex = int.Parse(context.Request.QueryString["pageindex"]) + 1;
        }
        //页显示行数
        if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
        {
            PageSize = int.Parse(context.Request.QueryString["pagesize"]);
        }
        strwhere = string.Format("UserId='{0}'", ShwoUserChangeData);
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(pageindex, PageSize, "Hr_PersonnelTransferInfo.TransTime desc", "Hr_PersonnelTransferInfo", strwhere, "Depart_O,Position_O,EmpLevel_O,Depart_N,Position_N,EmpLevel_N,TransType,TransTime", "Depart_O,Position_O,EmpLevel_O,Depart_N,Position_N,EmpLevel_N,TransType,Convert(varchar(10),TransTime,120) as TransTime", true);

        context.Response.Write(string.Format("{{success:'1',data:{{data:'{0}',count:{1}}}}}", CreateGrid("GetUserChange", ds.Tables[0].Select("1=1")), Convert.ToInt32(ds.Tables[1].Rows[0].ItemArray[0])));


        //System.Text.StringBuilder str = new System.Text.StringBuilder();
        //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //{
        //    string td = "";
        //    td = String.Format("<tr class='tab_line5'><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td>", ds.Tables[0].Rows[i][0], ds.Tables[0].Rows[i][1], ds.Tables[0].Rows[i][2], ds.Tables[0].Rows[i][3], ds.Tables[0].Rows[i][4], ds.Tables[0].Rows[i][5], ds.Tables[0].Rows[i][6], ds.Tables[0].Rows[i][7]);
        //    str.Append(td);
        //}
        //return str;
    }

    private StringBuilder GetPositionPowerCount()
    {
        string strwhere = "UserId='" + ShowPositionPowerCount + "'";
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(1, 1, "Addtime desc", "dbo.Hr_Struct_UserDepartRelation", strwhere, "RecordId", "RecordId", false);
        StringBuilder str = new StringBuilder();
        str.Append("{count:'" + ds.Tables[0].Rows[0][0].ToString() + "'}");
        return str;
    }

    private void GetPositionPowerData(HttpContext context)
    {
        int pageindex = 0;//页码
        int PageSize = 0;//页显示行数
        string strwhere = "";
        //页码        
        if (!string.IsNullOrEmpty(context.Request.QueryString["pageindex"]))
        {
            pageindex = int.Parse(context.Request.QueryString["pageindex"]) + 1;
        }
        //页显示行数
        if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
        {
            PageSize = int.Parse(context.Request.QueryString["pagesize"]);
        }
        strwhere = string.Format("UserId='{0}'", ShowPositionPowerData);
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(pageindex, PageSize, "dbo.Hr_Struct_UserDepartRelation.AddTime desc", "dbo.Hr_Struct_UserDepartRelation", strwhere, "DepartName,IsBelong,ComeDate,RoleType", "DepartName,case when IsBelong=1 then '√' else '' end as IsBelong,convert(nvarchar(10),ComeDate,120) as ComeDate,case RoleType when '1' then '业务员' when '2' then '秘书'  when '3' then '店长'  when '4' then '高经'  when '5' then '区经'  when '6' then '商经' else '总部人员' end as RoleType", true);

        context.Response.Write(string.Format("{{success:'1',data:{{data:'{0}',count:{1}}}}}", CreateGrid("GetPositionPower", ds.Tables[0].Select("1=1")), Convert.ToInt32(ds.Tables[1].Rows[0].ItemArray[0])));


        //System.Text.StringBuilder str = new System.Text.StringBuilder();
        //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //{
        //    string td = "";
        //    td = String.Format("<tr class='tab_line5'><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", ds.Tables[0].Rows[i][0], ds.Tables[0].Rows[i][1], ds.Tables[0].Rows[i][2], ds.Tables[0].Rows[i][3]);
        //    str.Append(td);
        //}
        //return str;
    }


    private StringBuilder GetBussinessCount()
    {
        string strwhere = "UserId='" + ShowBussinessCount + "'";
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(1, 1, "Addtime desc", "dbo.Struct_UserDepartRelation", strwhere, "RecordId", "RecordId", false);
        StringBuilder str = new StringBuilder();
        str.Append("{count:'" + ds.Tables[0].Rows[0][0].ToString() + "'}");
        return str;
    }

    private void GetBussinessData(HttpContext context)
    {
        int pageindex = 0;//页码
        int PageSize = 0;//页显示行数
        string strwhere = "";
        //页码        
        if (!string.IsNullOrEmpty(context.Request.QueryString["pageindex"]))
        {
            pageindex = int.Parse(context.Request.QueryString["pageindex"]) + 1;
        }
        //页显示行数
        if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
        {
            PageSize = int.Parse(context.Request.QueryString["pagesize"]);
        }
        strwhere = string.Format("UserId='{0}'", ShowBussinessData);
        string TableFieldList = "RecordId,UserCode,UserName,Company,DepartName,CASE WHEN IsBelong='1' THEN '√' ELSE '' END  AS IsBelong,CASE WHEN IsRoleA='1' THEN '√' ELSE '' END  AS IsRoleA,CASE WHEN IsRoleB='1' THEN '√' ELSE '' END  AS IsRoleB,CASE WHEN IsRoleC='1' THEN '√' ELSE '' END  AS IsRoleC,CASE WHEN IsRoleD='1' THEN '√' ELSE '' END  AS IsRoleD,CASE WHEN IsRoleE='1' THEN '√' ELSE '' END  AS IsRoleE,CASE WHEN IsRoleF='1' THEN '√' ELSE '' END  AS IsRoleF,CASE WHEN ViewPubHouse='1' THEN '√' ELSE '' END  AS ViewPubHouse,CASE WHEN ViewPrivHouse='1' THEN '√' ELSE '' END  AS ViewPrivHouse,CASE WHEN ViewHideHouse='1' THEN '√' ELSE '' END  AS ViewHideHouse,CASE WHEN ViewPrivDemand='1' THEN '√' ELSE '' END  AS ViewPrivDemand,CASE WHEN ViewRealCustomer='1' THEN '√' ELSE '' END  AS ViewRealCustomer,CASE WHEN ViewFakeCustomer='1' THEN '√' ELSE '' END  AS ViewFakeCustomer,CASE WHEN EditPrimaryHouse='1' THEN '√' ELSE '' END  AS EditPrimaryHouse,"
   + "CASE WHEN EditNormalHouse='1' THEN '√' ELSE '' END  AS EditNormalHouse,CASE WHEN DelTrace='1' THEN '√' ELSE '' END  AS DelTrace,CASE WHEN CanProtect='1' THEN '√' ELSE '' END  AS CanProtect,CASE WHEN CanLockHouse='1' THEN '√' ELSE '' END  AS CanLockHouse,CASE WHEN ViewLockHouse='1' THEN '√' ELSE '' END  AS ViewLockHouse,CASE WHEN ViewChange='1' THEN '√' ELSE '' END  AS ViewChange,CASE WHEN CanChangeConfirm='1' THEN '√' ELSE '' END  AS CanChangeConfirm,CASE WHEN ViewEntrust='1' THEN '√' ELSE '' END  AS ViewEntrust,CASE WHEN CanCancelTrust='1' THEN '√' ELSE '' END  AS CanCancelTrust,CASE WHEN UnCancelTrust='1' THEN '√' ELSE '' END  AS UnCancelTrust,CASE WHEN CanDelTrust='1' THEN '√' ELSE '' END  AS CanDelTrust,CASE WHEN ViewHrInfo='1' THEN '√' ELSE '' END  AS ViewHrInfo,CASE WHEN ViewHrChange='1' THEN '√' ELSE '' END  AS ViewHrChange,CASE WHEN ViewAttendance='1' THEN '√' ELSE '' END  AS ViewAttendance,"
   + "CASE WHEN ViewWatching='1' THEN '√' ELSE '' END  AS ViewWatching,CASE WHEN EditWatching='1' THEN '√' ELSE '' END  AS EditWatching,CASE WHEN EditKey='1' THEN '√' ELSE '' END  AS EditKey,CASE WHEN UseKey='1' THEN '√' ELSE '' END  AS UseKey,CASE WHEN EditKeyUsing='1' THEN '√' ELSE '' END  AS EditKeyUsing,CASE WHEN EditTrust='1' THEN '√' ELSE '' END  AS EditTrust,CASE WHEN CancelLockHouse='1' THEN '√' ELSE '' END  AS CancelLockHouse,CASE WHEN ViewPrivCustomer='1' THEN '√' ELSE '' END  AS ViewPrivCustomer,CASE WHEN EditPubDemand='1' THEN '√' ELSE '' END  AS EditPubDemand,CASE WHEN EditPrivDemand='1' THEN '√' ELSE '' END  AS EditPrivDemand,CASE WHEN ViewTelLog='1' THEN '√' ELSE '' END  AS ViewTelLog,CASE WHEN ViewBusiness='1' THEN '√' ELSE '' END  AS ViewBusiness,"
   + "CASE WHEN ViewVacation='1' THEN '√' ELSE '' END  AS ViewVacation,CASE WHEN ViewAnnualLeave='1' THEN '√' ELSE '' END  AS ViewAnnualLeave,CASE WHEN ViewUserLog='1' THEN '√' ELSE '' END  AS ViewUserLog,CASE WHEN DelHouse='1' THEN '√' ELSE '' END  AS DelHouse,CASE WHEN EditPubCustomer='1' THEN '√' ELSE '' END  AS EditPubCustomer,CASE WHEN EditPrivCustomer='1' THEN '√' ELSE '' END  AS EditPrivCustomer,CASE WHEN ViewStock='1' THEN '√' ELSE '' END  AS ViewStock,CASE WHEN IsControl='1' THEN '√' ELSE '' END  AS IsControl,"
   + "CASE WHEN ShiftPubCustomer='1' THEN '√' ELSE '' END  AS ShiftPubCustomer,CASE WHEN SetPubLevel='1' THEN '√' ELSE '' END  AS SetPubLevel,CASE WHEN ViewCrossPubShareDemand='1' THEN '√' ELSE '' END  AS ViewCrossPubShareDemand,CASE WHEN ViewPubShareDemand='1' THEN '√' ELSE '' END  AS ViewPubShareDemand,CASE WHEN ViewCrossPubShareCustomer='1' THEN '√' ELSE '' END  AS ViewCrossPubShareCustomer,CASE WHEN ViewPubShareCustomer='1' THEN '√' ELSE '' END  AS ViewPubShareCustomer,CASE WHEN viewtrace='1' THEN '√' ELSE '' END  AS viewtrace,CASE WHEN CanDeletePicture='1' THEN '√' ELSE '' END  AS CanDeletePicture,CASE WHEN CanUploadPicture='1' THEN '√' ELSE '' END  AS CanUploadPicture,CASE WHEN CanPublishHouse='1' THEN '√' ELSE '' END  AS CanPublishHouse";
        string FieldList = "RecordId,UserCode,UserName,Company,DepartName,IsBelong,IsRoleA,IsRoleB,IsRoleC,IsRoleD,IsRoleE,ViewPubHouse,ViewPrivHouse,ViewHideHouse,ViewPrivDemand,ViewRealCustomer,ViewFakeCustomer,EditPrimaryHouse,EditNormalHouse,DelTrace,CanProtect,CanLockHouse,ViewLockHouse,ViewChange,CanChangeConfirm,ViewEntrust,CanCancelTrust,UnCancelTrust,CanDelTrust,ViewWatching,EditWatching,EditKey,UseKey,EditKeyUsing,EditTrust,CancelLockHouse,ViewPrivCustomer,EditPubDemand,EditPrivDemand,ViewTelLog,ViewBusiness,ViewHrInfo,ViewHrChange,ViewAttendance,ViewVacation,ViewAnnualLeave,ViewUserLog,DelHouse,EditPubCustomer,EditPrivCustomer,ViewStock,IsControl,ShiftPubCustomer,SetPubLevel,ViewCrossPubShareDemand,ViewPubShareDemand,ViewCrossPubShareCustomer,ViewPubShareCustomer,viewtrace,CanDeletePicture,CanUploadPicture,CanPublishHouse";
        DataSet ds = Chenxin.Lib.Hr.DAL.Hr_PersonnelTransferInfo.GetList(pageindex, PageSize, "dbo.Struct_UserDepartRelation.AddTime desc", "dbo.Struct_UserDepartRelation", strwhere, FieldList,TableFieldList, true);

        context.Response.Write(string.Format("{{success:'1',data:{{data:'{0}',count:{1}}}}}", CreateGrid("GetBussinessData", ds.Tables[0].Select("1=1")), Convert.ToInt32(ds.Tables[1].Rows[0].ItemArray[0])));


        //System.Text.StringBuilder str = new System.Text.StringBuilder();
        //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //{
        //    string td = "";
        //    td = String.Format("<tr class='tab_line5'><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td><td>{9}</td><td>{10}</td><td>{11}</td><td>{12}</td><td>{13}</td>", ds.Tables[0].Rows[i][0], ds.Tables[0].Rows[i][1], ds.Tables[0].Rows[i][2], ds.Tables[0].Rows[i][3], ds.Tables[0].Rows[i][4], ds.Tables[0].Rows[i][5], ds.Tables[0].Rows[i][6], ds.Tables[0].Rows[i][7], ds.Tables[0].Rows[i][8], ds.Tables[0].Rows[i][9], ds.Tables[0].Rows[i][10], ds.Tables[0].Rows[i][11], ds.Tables[0].Rows[i][12], ds.Tables[0].Rows[i][13]);
        //    str.Append(td);
        //}
        //return str;
    }


    /// <summary>
    /// 生成列表
    /// </summary>
    /// <param name="drList"></param>
    /// <returns></returns>
    public string CreateGrid(string type, DataRow[] drList)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (type == "GetUserChange")
        {
            sb.Append("<table id=\"UserChange_Table\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" style=\"text-align: center;\" cellspacing=\"0\">");
            sb.Append("<tr class=\"tab_line4\"><td width=\"15%\"><b>老门店</b></td><td width=\"10%\"><b>老职务</b></td>");
            sb.Append("<td width=\"15%\"><b>老职级</b></td><td width=\"15%\"><b>新门店</b></td><td width=\"10%\"><b>新职务</b></td>");
            sb.Append("<td width=\"15%\"><b>新职级</b></td><td width=\"8%\"><b>变动类型</b></td><td><b>变动时间</b></td></tr>");
            foreach (DataRow dr in drList)
            {
                sb.AppendFormat("<tr class=\"tab_line5\"><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td>", dr["Depart_O"], dr["Position_O"], dr["EmpLevel_O"], dr["Depart_N"], dr["Position_N"], dr["EmpLevel_N"], dr["TransType"], dr["TransTime"]);

            }
            sb.Append("</table>");
        }
        else if (type == "GetPositionPower")
        {
            sb.Append("<table id=\"PositionPower_Table\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" style=\"text-align: center;\" cellspacing=\"0\">");
            sb.Append("<tr class=\"tab_line4\"><td width=\"20%\"><b>部门</b></td><td width=\"15%\"><b>隶属</b></td><td width=\"30%\"><b>入职时间</b></td><td width=\"30%\"><b>岗位</b></td></tr>");
            foreach (DataRow dr in drList)
            {
                sb.AppendFormat("<tr class=\"tab_line5\"><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", dr["DepartName"], dr["IsBelong"], dr["ComeDate"], dr["RoleType"]);
            }
            sb.Append("</table>");
        }
        else if (type == "GetBussinessData")
        {
            sb.Append("<table id=\"BussinessData_Table\" style=\"width:4660px;auto;text-align: center;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
            sb.Append("<thead><tr class=\"tab_line4\">");
            sb.Append("<th width=\"100\">工号</th>");
            sb.Append("<th width=\"120\">姓名</th>");
            sb.Append("<th width=\"60\" >公司</th>");
            sb.Append("<th width=\"60\" >部门</th>");
            sb.Append("<th width=\"40\" >隶属</th>");
            sb.Append("<th width=\"40\" >管辖</th>");
            sb.Append("<th width=\"45\" >业务员</th>");
            sb.Append("<th width=\"40\" >秘书</th>");
            sb.Append("<th width=\"40\" >店长</th>");
            sb.Append("<th width=\"40\" >高经</th>");
            sb.Append("<th width=\"40\">区经</th>");
            sb.Append("<th width=\"40\">商经</th>");

            sb.Append("<th width=\"40\" >公盘</th>");
            sb.Append("<th width=\"40\" >私盘</th>");
            sb.Append("<th width=\"75\">查隐藏盘源</th>");
            sb.Append("<th width=\"60\">删除房源</th>");

            sb.Append("<th width=\"100\">客源公开级别</th>");

            sb.Append("<th width=\"60\">私客信息</th>");

            sb.Append("<th width=\"150\">查看部门共享客户</th>");
            sb.Append("<th width=\"150\">查看跨部门共享客户</th>");

            sb.Append("<th width=\"100\">转移公开客源</th>");

            sb.Append("<th width=\"60\">修改公客</th>");
            sb.Append("<th width=\"60\">修改私客</th>");

            //sb.Append("<th width=\"60\">公客需求</th>");
            sb.Append("<th width=\"60\">私客需求</th>");

            sb.Append("<th width=\"150\">查看部门共享客需</th>");
            sb.Append("<th width=\"150\">查看跨部门共享客需</th>");

            sb.Append("<th width=\"60\">修改公需</th>");
            sb.Append("<th width=\"60\">修改私需</th>");

            sb.Append("<th width=\"50\">真业主</th>");
            sb.Append("<th width=\"50\">假业主</th>");
            sb.Append("<th width=\"120\">修改房源关键字段</th>");
            sb.Append("<th width=\"130\">修改房源非关键字段</th>");
            sb.Append("<th width=\"60\">查看跟单</th>");
            sb.Append("<th width=\"60\">删除跟单</th>");
            sb.Append("<th width=\"90\">保护/取消保护</th>");
            sb.Append("<th width=\"60\">封盘操作</th>");
            sb.Append("<th width=\"60\">取消封盘</th>");

            sb.Append("<th width=\"60\">查看封盘</th>");

            sb.Append("<th width=\"60\">查看带看</th>");
            sb.Append("<th width=\"60\">修改带看</th>");
            sb.Append("<th width=\"60\">修改钥匙</th>");
            sb.Append("<th width=\"60\">钥匙使用</th>");
            sb.Append("<th width=\"100\">修改钥匙使用</th>");


            sb.Append("<th width=\"60\">查看变更</th>");
            sb.Append("<th width=\"60\">处理变更</th>");
            sb.Append("<th width=\"60\">查看委托</th>");
            sb.Append("<th width=\"60\">修改委托</th>");

            sb.Append("<th width=\"60\">作废委托</th>");
            sb.Append("<th width=\"60\">取消作废</th>");
            sb.Append("<th width=\"60\">删除委托</th>");

            sb.Append("<th width=\"100\">可查人事信息</th>");
            sb.Append("<th width=\"100\">可查人事变动</th>");
            sb.Append("<th width=\"60\">可查考勤</th>");
            sb.Append("<th width=\"60\">可查休假</th>");
            sb.Append("<th width=\"60\">可查年假</th>");
            sb.Append("<th width=\"60\">可查库存</th>");
            sb.Append("<th width=\"100\">可查电话日志</th>");
            sb.Append("<th width=\"100\">可查营业动态</th>");
            sb.Append("<th width=\"120\">可查用户操作日志</th>");

            sb.Append("<th width=\"120\">可上传房源图片</th>");
            sb.Append("<th width=\"120\">可删除房源图片</th>");
            sb.Append("<th width=\"100\">可推送房源</th>");
                
                sb.Append("</tr></thead>");

            
            foreach (DataRow dr in drList)
            {
                sb.AppendFormat("<tr id=\"{0}\" class=\"tab_line5\">", dr["RecordId"].ToString());
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "UserCode", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "UserName", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "Company", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "DepartName", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsBelong", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsControl", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleA", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleF", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleB", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleC", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleD", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "IsRoleE", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPubHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPrivHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewHideHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "DelHouse", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "SetPubLevel", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPrivCustomer", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPubShareCustomer", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewCrossPubShareCustomer", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ShiftPubCustomer", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditPubCustomer", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditPrivCustomer", ""));

                //                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPubDemand", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPrivDemand", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewPubShareDemand", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewCrossPubShareDemand", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditPubDemand", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditPrivDemand", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewRealCustomer", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewFakeCustomer", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditPrimaryHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditNormalHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "viewtrace", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "DelTrace", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanProtect", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanLockHouse", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CancelLockHouse", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewLockHouse", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewWatching", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditWatching", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditKey", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "UseKey", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditKeyUsing", ""));


                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewChange", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanChangeConfirm", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewEntrust", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "EditTrust", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanCancelTrust", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "UnCancelTrust", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanDelTrust", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewHrInfo", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewHrChange", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewAttendance", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewVacation", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewAnnualLeave", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewStock", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewTelLog", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewBusiness", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "ViewUserLog", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanUploadPicture", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanDeletePicture", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(dr, "CanPublishHouse", ""));

                sb.Append("</tr>");
            }
            sb.Append("<tbody>");
        }

        return sb.ToString();
    }

}